<?php

namespace app\common\validate;

use app\common\Result;
use think\Validate;

class BaseValidate extends Validate
{
    public function validate($scene = null, array $validateData = []): array
    {
        $params = input('param.');
        $params = array_merge($params, $validateData);

        if ($scene) {
            $result = $this->scene($scene)->check($params);
        } else {
            $result = $this->check($params);
        }

        if (!$result) {
            $msg = is_array($this->error) ? implode(';', $this->error) : $this->error;
            Result::httpException($msg);
        }

        return $params;
    }
}